package com.duobaoyu.dby.supply.db.repository.message.impl;

import com.duobaoyu.dby.supply.db.entity.message.MqMessageConsumer;
import com.duobaoyu.dby.supply.db.repository.message.MqMessageConsumerRepository;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName MqMessageConsumerServiceImpl
 * @createTime 11:28:00 2023/10/07
 */
@Repository
@RequiredArgsConstructor
public class MqMessageConsumerRepositoryImpl /*extends DbyServiceImpl<MqMessageConsumerMapper, MqMessageConsumer> */implements MqMessageConsumerRepository {

    private final MongoTemplate mongoTemplate;

    @Override
    public boolean save(MqMessageConsumer mqMessageConsumer) {
        MqMessageConsumer save = mongoTemplate.save(mqMessageConsumer);
        return Optional.ofNullable(save).map(MqMessageConsumer::getId).map(StringUtils::isNotBlank).orElse(false);
    }
}
